text:
# Insights Either the Sun Is Getting Smaller or Gravity Is Getting Weaker

Tags:
1. Apr 8, 2018

2. Apr 8, 2018

### Staff: Mentor

Very interesting. There's a minor LaTeX error after "77,000,000,000".
And last but not least a good reference to quote on the FAQ "Do constants change over time or space?"

3. Apr 8, 2018

### JMz

To one point: The Solar System -- the orbital radii of the planets and other bodies -- could be getting larger as the Sun's mass slowly shrinks. However, it could also be getting smaller, due to friction from the solar wind. (Also radiation pressure, in the case of tiny bodies, especially dust.) The getting-larger effect should apply equally to all bodies, and the increase should be a simple proportionality with distance. But the getting-smaller effect(s) should be greater at smaller solar distances and for less dense bodies. Which effect is dominant, and for which bodies?

4. Apr 8, 2018

### Greg Bernhardt

Really enjoyed this Insight!

5. Apr 8, 2018

### Staff: Mentor

There is also one at "1026 Watts"

> Together, the predicted mass loss rate is consistent with the measured decreasing gravitational parameter given its uncertainty.
So... we expect a mass loss, and we see the effect of the mass loss in the expected amount. Nothing surprising, unlike the topic would suggest.

6. Apr 8, 2018

### Drakkith

Staff Emeritus
Some would hope the Earth's gravity is getting weaker. It would certainly make people feel better after the end of year holiday dinners.

7. Apr 9, 2018

### Brazedowl

Well isn't the momentum of the solar wind directed, for the most part, directly away from the sun? So it would contribute to an expansion overall, yes? Perhaps when the charged particles interact with magnetic fields of (some) planetary bodies and they're deflected? But still seems like an "outward" directed force.

8. Apr 9, 2018

### Staff: Mentor

A uniform outwards force does not increase orbits, it gives them a different period. It acts like a slightly lower (but constant) solar mass. What is left is some sort of friction, which decreases the orbital radius of objects over time.

9. Apr 11, 2018

### Chronos

Isn't sixty parts per quadrillion decrease in gravity per year smaller than the uncertainty in the gravitational constant given by CODATA?

10. Apr 11, 2018

### Staff: Mentor

Yes. So what?
What astronomers measure is not the gravitational constant, but the product of the gravitational constant and the mass of objects, GM. This product can be measured much more precisely than either G or M.

11. Apr 12, 2018

### JMz

Yes. So in principle, the title of this thread is misleading: The product is decreasing, but (a) it could be either or (b) it could be both or (c) one could be increasing slightly but the other decreasing more.

12. Apr 20, 2018

### fluidistic

I'm curious if they took into account the momentum of the EM field (or photons) created by the Sun exerted on the planets (and the black body radiation of the planets and cosmic background blackbody radiation). By intuition, even though Mercury is a small planet, it's very close to the Sun and might be the most affected to it.

13. Apr 20, 2018

### JMz

This is covered by @mfb's post #8 here (even though that was stated in the context of the solar wind).

14. Apr 26, 2018

### Chronos

It is very difficult to draw any meaningful conclusions about individual factor variance based on the product of individual factors across cosmological time scales.

15. May 1, 2018

### fluidistic

Does this mean that if the Sun was, say, so shiny that the outward force more than counteract the gravitational force between the Earth and the Sun, the Earth would still have its orbit intact?

I do not understand how the Earth could stay with the same orbit if the photons hitting them from the Sun were so much more numerous than they are now that the outward force would be so great that there should not be any stable orbit. Am I missing something?

16. May 2, 2018

### Staff: Mentor

No, of course not. These particles are not in an orbit at all. That only affects particles smaller than ~500 nm, however.

17. May 2, 2018

### ensign_nemo

Has anyone calculated the loss of energy from the gravitational waves emitted by the Sun and Jupiter, or the Sun and the other gas giants?

For the Sun and Jupiter,

m1 = 1.989 × 10^30 kg (Sun) ~ 2 × 10^30 kg
m2 = 1.898 × 10^27 kg (Jupiter) = 0.0009543 m1 ~ 2 × 10^27 kg
R = 778.5 million km = 7.785 x 10^11 m ~ 8 x 10^11 m

The best reference I could find with a quick Google search was:

http://www.physics.usu.edu/Wheeler/GenRel2013/Notes/GravitationalWaves.pdf

but I'm not familiar enough with the formulas to be confident that I'm applying them correctly.

18. May 2, 2018

### Staff: Mentor

About 200 W for Earth/Sun, a bit more for Jupiter. Wikipedia has formulas where you can just plug in masses, distances and eccentricities (use e=0 for a good approximation).

19. Jun 4, 2018

### TZT

Some of you likely already know some of the following, but it was a very interesting point, about the Sun, when I heard it.

Jupiter is massive, and so is the Sun. Given the mass of Jupiter it has great total gravitational force. That force also is exerted noticeably on the Sun itself.
Due to the gravitational force of Jupiter it actually affects the Sun's position in our solar system, such that the Sun is not in a constant epicenter where all the planets form their orbits around that constant point. Rather, Jupiter's gravity pulls on the Sun such that the Sun also has an "orbit", and it's orbit is around an imaginary point that the sun orbits around. So, the Sun itself is also pulled towards Jupiter as Jupiter is pulled towards the sun, and their respective gravity creates both Jupiters's orbit as well as giving the Sun an "orbit" that is around the "center" of the solar system.

Very cool. And it demonstrates the massive gravitational power of Jupiter.

Question:
As the Sun's mass lessens, and with that it's gravitation force lessens, then at what point in the future will Jupiter's gravity have a greater effect on the planets between it and the Sun? IOW, at some future point, will Jupiter's gravitational effect become stronger on the Earth as the Sun's gravitational effect becomes lesser? And, when, or if, that happens, will the Earth's orbit change? Will the effect of Jupiter's gravitational pull slow the Earth's orbit around the sun? Or, can it create an effect of a slow orbit during certain Earth to Jupiter orbiting positions, and then speed up the orbit during different relative positions?

This of course is predicated on the idea that the Sun's mass is lessened due mainly to fusion and mass coronal ejections, while Jupiter's mass remains constant over this same period.

20. Jun 4, 2018

### Staff: Mentor

This is true of all the planets, not just Jupiter. Jupiter's effect is by far the largest, but I don't think it's the only detectable one. The strictly correct statement is that all of the objects in the Solar system orbit its barycenter, which can be thought of as the "center of mass" of the system as a whole, and this barycenter does not coincide with the center of any of the objects, including the Sun.

Never. The rate of mass loss of the Sun is much, much too small. The sun is over 1100 times as massive as Jupiter, and the mass loss rate is roughly 6 parts in $10^{14}$ per year, so even after 5 billion years more, when the Sun is expected to become a red giant, the Sun will have lost only about 1 part in 100,000 of its current mass, so it will still be over 1100 times as massive as Jupiter.

21. Jun 4, 2018

### TZT

Soooo, you're sayin there's a chance!? LOL.

Last edited: Jun 4, 2018
22. Jun 4, 2018

### TZT

Well now, of course Jupiter's gravity affects all the planets, as all the planets can affect each other. But now, that wasn't the point, and that's not what I was asking or talking about.

[Moderator's note: rest of post deleted as it was off topic.]

Last edited by a moderator: Jun 4, 2018
23. Jun 4, 2018

### Staff: Mentor

24. Jun 5, 2018

### Staff: Mentor

Both Jupiter and Saturn contribute notably to the position of the Sun relative to the barycenter of the Solar System. Saturn has a smaller mass but the larger distance means it still plays a relevant role.

Wikipedia has an image - the 12 year period comes from Jupiter and the perturbation of that cycle comes from Saturn, with smaller contributions from other planets.


text:
# Huntsman Telephoto Array specifications

## Introduction

The Huntsman Telephoto Array is an astronomical imaging system consisting of 1-10 imaging units attached to a telescope mount. The concept is closely based on the Dragonfly Telephoto Array, pictured below.

### Imaging units

Each imaging unit comprises a Canon EF 400mm f/2.8L IS II USM camera lens, an SBIG STF-8300M ccd camera and an adaptor from Birger Engineering. The prototype imaging unit ('the Huntsman Eye') is shown below. The tripod adaptor bracket is bolted to the main lens body, this bracket could be removed and the bolt holes used for direct attachment to a support structure.

### Telescope mount

The Huntsman Telephoto Array will use a Software Bisque Paramount ME II telescope mount. A Solidworks eDrawing is available as part of the mount documentation set.

### Support structure

The Huntsman Telephoto Array support structure must enable the imaging units to be assembled into an array and attached to the telescope mount. The Dragonfly Telephoto Array has adopted a modular solution based on tubular structures around each lens, as can be seen in the photo below.

### Enclosure

The Huntsman Telephoto Array is expected to be housed in an Astro Dome 4500, a 4.5 metre diameter telescope dome with a 1.2 metre wide aperture. A 21 year old example at Mt Kent Observatory is shown below.

## Science requirements

### Spatial sampling

Derived from the specifications of the chosen hardware.

In [1]:

import math
from astropy import units as u

pixel_pitch = 5.4 * u.micron / u.pixel # STF-8300M pixel pitch
focal_length = 400 * u.millimeter # Canon EF 400 mm f/2.8L IS II USM focal length
resolution = (3326, 2504) * u.pixel # STF-8300M resolution in pixels, (x, y)

sampling = (pixel_pitch / focal_length).to(u.radian/u.pixel, equivalencies = u.equivalencies.dimensionless_angles())
sampling.to(u.arcsec/u.pixel)

Out[1]:

$2.7845749 \; \mathrm{\frac{{}^{\prime\prime}}{pix}}$

• Each imaging unit shall deliver an on-sky spatial sampling of $2.8\pm 0.1'' /$ pixel

### Field of view

Derived from the specifications of the chosen hardware.

In [2]:

fov = resolution * sampling
fov.to(u.degree)

Out[2]:

$[2.5726378,~1.9368265] \; \mathrm{{}^{\circ}}$

• Each imaging unit shall deliver an instantaneous field of view of $2.6 \pm 0.1 \times 1.9 \pm 0.1$ degrees

### Exposure time

Individual exposure times of 5-30 minutes are anticipated (5-10 minutes for broadband observations, 30 minutes for narrowband).

In [5]:

exposure_times = ((5, 10, 30) * u.minute)
exposure_times

Out[5]:

$[5,~10,~30] \; \mathrm{min}$

• The system shall meet all requirements with exposure times of up to 30 minutes

### Number of imaging units

The maximum number of imaging units per telescope mount is really determined by the mount payload mass limit and the aperture size of the enclosure. The Dragonfly Telephoto Array are currently operating with 10 imaging units on a single mount, the Huntsman Telephoto Array should be capable of at least matching this.

In [7]:

n_units = (1, 4, 10)
n_units

Out[7]:

(1, 4, 10)

• The system shall support up to at least 10 imaging units per telescope mount

### Imaging unit alignment

Given the large field of view tight coalignment of individual imaging units is not required, or even particularly desirable.

In [9]:

coalignment_tolerance = 5 * u.arcminute
coalignment_tolerance

Out[9]:

$5 \; \mathrm{{}^{\prime}}$

• All imaging units should point in the same direction to within a tolerance of 5 arcminutes radius on sky (TBC)

All data will be resampled prior to combination so some relative rotation between imaging units is acceptable.

In [10]:

north_alignment_tolerance = 2.5 * u.degree
north_alignment_tolerance

Out[10]:

$2.5 \; \mathrm{{}^{\circ}}$

• All imaging units shall have the camera y axis aligned with the North-South axis to within a tolerance of $\pm$2.5 degrees (TBC)

### Image quality

Abraham & van Dokkum (2014) report that imaging units of the design proposed for the Huntsman Telephoto Array are capable of producing a point spread function (PSF) with full width at half maximum (FWHM) of $\sim1.5''$, as measured by (undersampled) 3rd order polynomial fitting by SExtractor. When image sensor tilts (PSF degradation $<0.4''$) and imperfect telescope tracking are taken into account average FWHM of $< 2''$ were still achieved across the entire field of view. The Huntsman Telephoto Array should at least match this.

In [19]:

central_fwhm = 1.5 * u.arcsecond
max_fwhm = 2 * u.arcsecond
max_fwhm

Out[19]:

$2 \; \mathrm{{}^{\prime\prime}}$

• The system shall deliver a PSF with average FWHM $< 2''$ over the full field of view, as measured using a 3rd order polynomial fit performed wth the SExtrator software

### Filters

For the primary science project we anticipate using SDSS-type g & r bandpass filters, typically with half of the imaging units equipped with one and half with the other though there may be targets for which we would want to use a different mix of filters. During bright of Moon it will not be possible to make useful observations for the primary science project and so during these times we may use narrowband filters, e.g. H-$\alpha$. To do this it must be possible to change filters between nights but it is not necessary that this be a motorised/automated process.

• Each imaging unit shall be equipped with an optical bandpass filter
• It must be possible to change filters between nights
• The set of filters shall contain at least one SDSS-type filter of either g or r band for each imaging unit

### Sky coverage

The system should allow the observation of targets at any position on the sky that corresponds to a reasonable airmass, i.e. $<2$.

In [49]:

max_zenith_distance = 60 * u.degree
max_zenith_distance

Out[49]:

$60 \; \mathrm{{}^{\circ}}$

• The system shall satisfy all functional requirements (e.g. image quality, alignment) while observing any sky position with a zenith distance less than 60 degrees. The system is not required to meet functional requirements if observing a sky position with a zenith distance of greater than 60 degrees

## Mechanical requirements

### Support structure(s)

• The mechanical support structure(s) shall allow the number of imaging units specified in the science requirements to be attached to the telescope mount

In [34]:

n_units

Out[34]:

(1, 4, 10)

### Imaging unit interface

• The support structure(s) shall attach to the imaging units via the Canon EF 400mm f/2.8L IS II USM camera lens tripod mount bolt hole pattern and/or clamping of the camera lens body

### Telescope mount interface

• The support structure(s) shall attach to the telescope mount via the standard interface plate, the Paramount ME II Versa-Plate (drawing here)

### Alignment

• The support structure(s) shall ensure that the imaging units are aligned to within the tolerances specified in the science requirements

In [16]:

coalignment_tolerance

Out[16]:

$5 \; \mathrm{{}^{\prime}}$

In [17]:

north_alignment_tolerance

Out[17]:

$2.5 \; \mathrm{{}^{\circ}}$

### Flexure

The support structure(s) must be rigid enough so that flexure will not prevent the system from achieving the image quality specification from the science requirements. This requires the pointing of all imaging units to remain constant relative to either the telescope mount axes (if not autoguiding) or the autoguider pointing (if using autoguiding) to within a set tolerance for the duration of any individual exposure.

The tolerance can be calculated from the delivered image quality specification and expected imaging unit image quality.

In [23]:

fwhm_to_rms = (2 * (2 * math.log(2))**0.5)**-1
max_flexure_rms = fwhm_to_rms * (max_fwhm**2 - (central_fwhm + tilt_fwhm_degradation)**2)**0.5
max_flexure_rms

Out[23]:

$0.26520065 \; \mathrm{{}^{\prime\prime}}$

A given exposure time corresponds to an angle of rotation about the telescope mount hour angle axis.

In [30]:

ha_angles = (exposure_times.to(u.hour) * (u.hourangle / u.hour)).to(u.degree)
ha_angles

Out[30]:

$[1.25,~2.5,~7.5] \; \mathrm{{}^{\circ}}$

• The support structure(s) shall ensure that the pointing of all imaging units shall remain fixed relative to the telescope mount axes to within 0.27 arcseconds rms while the hour angle axis rotates through any 7.5 degree angle, for any position of the declination axis, within the sky coverage requirement's zenith distance range

In [33]:

max_zenith_distance

Out[33]:

$60 \; \mathrm{{}^{\circ}}$

### Mass

The telescope mount is rated for a maximum payload (not including counterweights) of 109 kg, therefore the total mass of imaging units plus support structure(s) should not exceed this value. The mass of the lens is 4.1 kg (source here), the mass of the CCD camera is 0.8 kg (source here) and the mass of the adaptor is estimated to be no more than 0.2 kg.

In [40]:

lens_mass = 4.1 * u.kilogram
camera_mass = 0.8 * u.kilogram
imaging_unit_mass = lens_mass + camera_mass + adaptor_mass

max_struture_mass = max_payload_mass - max(n_units) * imaging_unit_mass
max_struture_mass

Out[40]:

$58 \; \mathrm{kg}$

• The total mass of all support structure(s) shall be less than 58 kg

### Footprint

The support structure(s) needs to position the imaging units such that their combined beam footprint will pass through the dome aperture without vignetting. Translating this requirement into an allowed space envelope for the imaging units is not straightforward as the geometry is complicated: the axes of the telescope mount will be offset from each other, from the geometric centre of the dome and from the centre of the imaging unit array. 3D modelling of the mount, imaging unit array and enclosure will be required to verify this for all sky positions however as a general principle the imaging units should be as closely packed as possible to minimise the overall size of their combined beam footprint.

## Environmental

The system is intended to be placed at a moderate altitude site in mainland Australia. The expected ranges of environmental conditions during operation and storage are as follows.

In [ ]:

format: plain


text:
# Partitions of $\mathbb{R}^d$

Let $$\mathbb{R}^d=\Pi_{i=1}^d \mathbb{R},$$ does there exist a covering $$\{E_n:n\in \mathbb{Z}^d\}$$ of subsets $$E_n\subseteq \mathbb{R}^d$$ that satisfies the following: $$1)$$ $$E_n$$'s are pairwise disjoint, $$2)$$ for any $$x \in E_n, y\in E_m,$$ $$x+y\in E_{n+m},$$ and $$3)$$ $$\sup_{n\in \mathbb{Z}^d}|E_n|<\infty?$$ Note that I'm using $$|M|$$ to denote the Lebesgue measure of any measurable set $$M\subseteq \mathbb{R}^d.$$

The collections given by $$\{n+[0,1)^{d} : n\in \mathbb{Z}^d \}$$ easily comes to mind, but it doesn't seem to satisfy condition $$2$$ with some easy counterexample like $$(1+0.5)+(2+0.5)=3+1\neq 3+q_3$$ where $$0\leq q_3<1$$ in the case $$d=1$$.

• the first equation looks nonsense to me – mathworker21 Dec 7 at 9:26
• Does the empty set cover $\mathbb{R}^d?$ – Kurome Dec 7 at 9:27
• I don't think so if the sets should be measurable. Say focus on the real line. Some $E_n$ must have positive measure. Then $E_{2n}$ contains $E_n+E_n$, so by Steinhaus theorem (sum version math.stackexchange.com/questions/86209/…) it also contains an interval. But then $E_{4n}, E_{6n}$ and so on must contain longer and longer intervals. I haven't thought the details through though. – Michal Adamaszek Dec 7 at 9:40
• Hmmm, the theorem doesn't seem to say anything about the sizes of the contained intervals. – Kurome Dec 7 at 10:00
• No but if $U$ contains an interval of length $a$ and $V$ contains an interval of length $b$ then surely $U+V$ contains an interval of length $a+b$. – Michal Adamaszek Dec 7 at 10:03


text:
# Resistance equivalent formula

R=V/I: Resistance is the quotient of voltage (V) ÷ current (I).

• V=IR: Voltage (V) is the product of current (I) * resistance (R).
• I=V/R: Current is the quotient of voltage (V) ÷ resistance (R).
• R=V/I: Resistance is the quotient of voltage (V) ÷ current (I).

The sum of the current in each individual branch is equal to the current outside the branches. The equivalent or overall resistance of the collection of resistors is given by the equation 1/Req = 1/R1 + 1/R2 + 1/R3

## How to determine the equivalent resistance?

The equivalent resistance of a number of resistors connected in parallel can be computed using the reciprocal of the resistance i.e. frac{1} {R}. The reciprocal of the equivalent resistance will be equal to the sum of the reciprocals of each resistance.

## What is meant by equivalent resistance?

What is Meant by the Equivalent Resistance? In Physics, an equivalent Resistance is defined as the sum of the resistance of the resistors connected in a circuit. The resistors can be connected in series or parallel. Assume that R1, R2 and R3 be the three resistors

## What is equivalent resistance of ideal voltage source?

r = 0. Thus, the internal resistance of an ideal voltage source is always zero. However, no such source exists in the world. All the sources of voltage have some series connected internal resistance and hence its terminal voltage vary with current I as per (1). Such sources are called practical / real voltage source.

## What is equivalent resistance physics?

• Equivalent resistance is a purely resistive property, which does not change with any other variable. Effective resistance is another name given to the impedance. • Impedance is a property, which changes with the frequency of the signal. Equivalent resistance is defined to a set of resistors or components having resistance only.

## How do you find the equivalent resistance?

The equivalent resistance is the algebraic sum of the resistances (Equation 10.3. 2): RS=R1+R2+R3+R4+R5=20Ω+20Ω+20Ω+20Ω+10Ω=90Ω. The current through the circuit is the same for each resistor in a series circuit and is equal to the applied voltage divided by the equivalent resistance: I=VRS=9V90Ω=0.1A.

## What is a equivalent resistance?

The equivalent resistance is where the aggregate resistance connected either in parallel or series is calculated. Essentially, the circuit is designed either in Series or Parallel. Electrical resistance shows how much energy one needs when you move the charges/current through your devices.

## What is equivalent resistance of a circuit?

Equivalent Resistance: The equivalent resistance of a circuit is the total electrical resistance caused by all of the resistors in the circuit acting together against the voltage source. The following two problems demonstrate how to calculate equivalent resistance in a parallel circuit.

## What is the equivalent resistance of the resistors?

The equivalent resistance of a set of resistors in a series connection is equal to the algebraic sum of the individual resistances. Figure 6.2. 2 (a) Three resistors connected in series to a voltage source. (b) The original circuit is reduced to an equivalent resistance and a voltage source.

## How do you solve equivalent resistance problems?

Find equivalent resistance of the network. Find current in each resistor. Find voltage drops VAB,VBC,VCD. Medium.

## How do you find equivalent resistance in parallel?

How do you calculate two resistors in parallel? Take their reciprocal values, add the two together and take the reciprocal again. For example, if one resistor is 2 Ω and the other is 4 Ω, then the calculation to find the equivalent resistance is 1 / (1/2 + 1/4) = 1 / (3/4) = 4/3 = 1.33.

## How do you calculate resistance in a circuit?

If you know the total current and the voltage across the whole circuit, you can find the total resistance using Ohm’s Law: R = V / I. For example, a parallel circuit has a voltage of 9 volts and total current of 3 amps. The total resistance RT = 9 volts / 3 amps = 3 Ω.

## How do you find the equivalent resistance between a and B?

Solution : In (Fig. 3.22) (a), total resistance in the path ACB, i.e., R_1 = 8.5 Omega + 3.5 Omega = 12 Omega
Since R_1 and R_2 are in parallel, the effective resistance between the points A and B, i.e.,
R = (R_1 R_2)/(R_1 + R_2) = (3 xx 12)/(3 + 12) Omega = 2.4 Omega
In (Fig.

## How can 3 resistors of resistances?

How can three resistors of resistances 2 , 3 , and 6 be connected to give a total resistance of (a) 4 , (b) 1 ? Answer : (i) We can get a total resistance of 4 by connecting the 2 resistance in series with the parallel combination of 3 and 6 .

## What is the equivalent resistance of two resistors in parallel?

Two identical resistors in parallel have an equivalent resistance half the value of either resistor.

## What is equivalent resistance in series and parallel?

The method of calculating the circuits equivalent resistance is the same as that for any individual series or parallel circuit and hopefully we now know that resistors in series carry exactly the same current and that resistors in parallel have exactly the same voltage across them.

## What is the equivalent resistance of two resistors in series?

The equivalent resistance of two resistors connected in series is the sum of the individual resistances. Figure 19: Two resistors connected in parallel. The reciprocal of the equivalent resistance of two resistances connected in parallel is the sum of the reciprocals of the individual resistances.

## What is equivalent resistance between a and B?

Therefore, equivalent Resistance between A and B is 5Ω

## What is the difference between equivalent resistance and total resistance?

The resistance is measured in Ohms. The equivalent resistance of a system is the value of the single resistor that can be used instead of a combination of resistors. For a serial connection of resistors, the equivalent resistance is simply the addition of the resistors.

## How do you find the equivalent resistance of a triangle?

Equivalent of R′ and RAB can be calculated using formula, REQ=R+RRR⟹REQ=160+40160×40=32Ω

## What is the Equivalent Resistance?

The equivalent resistance is where the total resistance connected either in parallel or in series. Electrical resistance shows that how much energy will be required when we move the charges i.e. current through the circuit. If we need lots of energy, then the resistance necessary should also be high. The equivalent resistance of a network is the single resistor which can replace the entire network in such a way that for a certain applied voltage as V we will get the same current as I.

## What is the unit of resistance in electrical circuits?

The equivalent resistance of a number of resistors in series will be the sum of the individual resistances. The unit of resistance is the Ohm i.e. in symbol Omega.

## What does more resistance mean?

More resistance means for the less current flowing through the circuit. If the electrical circuit is having many resistances connected, then we need to find their accumulated resistance value. Thus, the equivalent resistance is a different way of indicating the total resistance. It will be calculated differently for series and parallel circuits.

## What is the Equivalent Resistance?

The equivalent resistance is defined as a common point or node where the total resistance is measured in a series or parallel arrangement (in either the whole circuit or in a fraction of the circuit).

## What is resistance in electrical engineering?

Answer: Resistance is the opposition that a material offers to the flow of electric current through it.

## Why use parallel arrangement of resistors?

In a place where there are fewer chances of an accident, we can use the parallel arrangement of resistors to avoid any mishappening. So, here the road is an electrical circuit and obstruction is the resistance.

## What is the purpose of a single resistor in an electrical network?

In the equivalent resistance of an electrical network, a single resistor can substitute the complete network so that a particular applied voltage or the equivalent current can be obtained similar to the one when utilized as a network.

## What does more resistance mean?

More resistance means less current flows through the circuit and vice-versa. The equivalent resistance is a different way of indicating ‘total effective’ resistance, which we calculate differently for series and parallel circuits. Share this with your friends. Share.

## What is resistance in a circuit?

Bookmark added to your notes. Resistance is the speed breaker that is connected to the circuit to protect it from the high current flow. When we connect two or more resistances in series or in parallel to each other, the security of the circuit increases.

## How many junctions does a resistor have?

Resistor comprises two junctions through which the current passes in and out. Resistors are passive devices that use electricity . In order to improve the total resistance, the resistors must be connected in series, and to reduce the resistance, the resistors must be connected in parallel.

## What is the equivalent resistance of a circuit?

The equivalent resistance of the circuit is the amount of resistance that a single resistor will require in order to equalise the total effect of the set of resistors present in the circuit. For parallel circuits, the equivalent resistance of a parallel circuit is given …

## What is resistance in electrical engineering?

Resistance is a measure of how much a device or material can resist the movement of electricity through it. It is inversely related to current, higher resistance means reduced current flow; reduced resistance means higher current flow.

## How many resistors are in a parallel circuit?

Although each branch gives 4 of resistance to any charge flowing through it, only one-half of all the charge flowing through the circuit may meet 4 of resistance of that branch. Thus, the presence of two 4 resistors in parallel will be equal to one 2 resistor in the circuit. This is the concept of equivalent resistance in a parallel circuit.

## How do resistors work?

In order to improve the net resistance, the resistors must be wired in series and the resistors must be connected in parallel to reduce the resistance.

## What happens when two resistors are wired in series?

Then the two resistors are wired in series and their equal resistance increases between their endpoints.

## How to find current through a battery?

To find the current through the battery we need to find the equivalent resistance of the circuit. The total current I is divided into and . The current passes through two resistors as they are connected in series and have the same current. The current passes through and resistors as they have the same current.

## What is the measure of how much a device or material can resist the movement?

When a circuit has more than one circuit component in it, there should be a way to calculate the total effective resistance of the entire circuit or for just one part of the circuit. Before we discuss what equal resistance is, we can describe resistance. Resistance is a measure of how much a device or material can resist the movement …

## What is the equivalent resistance in a series circuit

Series circuit: A series circuit is a circuit where the same current flows through each of its components. (It is different from a parallel circuit where the current is divided between the different components.)

## Examples of How to Calculate the Equivalent Resistance in a Series Circuit

A circuit contains three resistors with resistances of {eq}2\ \mathrm {k \Omega} {/eq}, {eq}500\ \mathrm {\Omega} {/eq} and {eq}300\ \mathrm {\Omega} {/eq} are connected in series. What is the equivalent resistance of the circuit?

## How to find equivalent resistance?

If R eq is the equivalent resistance of the circuit then it is calculated from adding the reciprocal values of individual resistances (1/R). The inverse of this algebraic sum will give the equivalent resistance. The equation for equivalent resistance R eq is shown below for a parallel resistive circuit of n resistors.

## What is the equivalent resistance of a parallel combination?

If two resistors of equal resistance R are connected in parallel combination then the equivalent resistance of the combination is R / 2.

## What is a resistor in parallel?

The concept of resistors in parallel is used in the analysis of Wheatstone bridge circuit. Resistors in parallel combination act as Current Divider Circuit. This current divider concept is use full in applications like Analog to Digital Converters and Digital to Analog Converters.

## Why is the current flowing through each resistor dependent on the resistance of that resistor?

Since the voltage across each resistor is same , the current flowing through each resistor is dependent on the resistance of that resistor. Hence if the resistance value in a branch is different from the other branch then the current in those branches will be different.

## How do resistors connect in parallel?

Introduction. Two resistors are said to be connected in parallel if both the terminals of a resistor are connected to each respective terminal of other resistor. In a network of parallel resistors, current can take more than one path unlike in series resistor network as there are multiple paths for the current to flow.

## What is the voltage across each resistor?

In parallel resistive circuits, the voltage across each resistor is same and is equal to the supply voltage.

## What is the potential difference between two or more resistors?

Resistors in Parallel. If two or more resistors are connected in parallel, then the potential difference across each resistor is same . Resistors in parallel connection are connected to the same nodes. This can be identified by the presence of more than one path for the current to flow.

## How to find equivalent resistance?

The equivalent resistance is calculated by making series and parallel connection of resistances. And find a value of equivalent resistance. This resistance is also known as Thevenin resistance (R th ).

## How to calculate Thevenin equivalent resistance?

To calculate the Thevenin equivalent resistance, remove all power sources from the original circuit. And voltage sources are short-circuited and current sources are opened. Hence, the remaining circuit has only resistances. Now, calculate the total resistance between the open connection points across load terminals.

## What is Thevenin’s Theorem (Thevenin Equivalent)?

Thevenin theorem (also known as the Helmholtz–Thévenin theorem) states that any linear circuit containing only voltage sources, current sources, and resistances can be replaced by an equivalent combination of a voltage source (V Th) in series with a single resistance (R Th) connected across the load. This simplified circuit is known as the Thevenin Equivalent Circuit.

## What is the circuit of Thevenin equivalent?

Thevenin equivalent circuit has a single loop. If we apply a KVL (Kirchhoff’s Voltage Law) to this loop, we can find the current passing through the load.

## What is the Thevenin equivalent circuit?

This simplified circuit is known as the Thevenin Equivalent Circuit. Thevenin’s theorem was invented by a French engineer Léon Charles Thévenin (hence the name). Thevenin theorem is used to convert a complex electrical circuit to a simple two-terminal Thevenin equivalent circuit. A Thevenin equivalent circuit contains one Thevenin resistance …

## What is the V EQ?

Thevenin equivalent voltage ( V eq) is equal to the open-circuit voltage measured across two terminals of load. This value of the ideal voltage source is used in Thevenin equivalent circuit.

## How to find current I 1 and I 2?

By solving equation-3 and 4; we can find the value of current I 1 and I 2. And current I 1 is the current that we need (I SC ).


text:
# Derivative help

1. Dec 28, 2005

### tman1

i was given a problem and found that
x = (VcosA)/g*(VsinA + ((VsinA)^2 + 2gYo)^1/2)
where x is the distance
v is the speed
A is the angle
g is the force of gravity
and Yo is the height
but i am a bit lost in taking its derivative. once i do so, i need to maximize and minimize the angle. i was wondering if i could get some help

2. Dec 28, 2005

### saltydog

Hey Tman, first write it nicely. Yea, I know you don't know LaTex yet but the prettier it is the fewer the mistakes. That's just how it is in math:

Looks like:

$$\frac{vCos(a)}{g}\left[vSin(a)+\left(v^2 Sin^2(a)+2gy_0\right)^{1/2}\right]$$

Now, use the chain rule:

$$d(uv)=udv+vdu$$

right?

I'll start it for you:

$$\frac{vCos(a)}{g}\frac{d}{da}\left[vSin(a)+\left(v^2 Sin^2(a)+2gy_0\right)^{1/2}\right]$$

Last edited: Dec 28, 2005
3. Dec 28, 2005

### tman1

little more help

i understand that i must use the chain rule, but i dont know which terms are constants, for example vcosA and 2gYo. would i have to make them equal zero because of constant rule or no

4. Dec 28, 2005

### saltydog

Tell you what, how about this: I don't know the details of your problem but for now, just assume everything other than 'a' is constant. Now, take the derivative of the expression with respect to a and work it though and see what happens.

So continuing:

$$\frac{vCos(a)}{g}\left[vCos(a)+1/2\left(v^2Sin^2(a)+2gy_0)^{-1/2}(2v^2Sin(a)Cos(a))\right)\right]$$

5. Dec 28, 2005

### tman1

i think i need alittle more guidance

ok so from this point where i have the derivative of what u gave me, i can set it equal to zero and find the maximum for the angle, or is there more that i still need to do(ie more deriving). also it would help me alot if u cud tell me where u got ur trig identies from (ie there derivatives) so i can later retry this by myself.

6. Dec 28, 2005

### saltydog

That was just half of the derivative.

Tman . . . I don't wish to add complexity to this for you. So start with:

$$x=f(a)=\frac{vCos(a)}{g}\left[vSin(a)+\left(v^2 Sin^2(a)+2gy_0\right)^{1/2}\right]$$

and calculate the derivative (assuming all other parameters are constants):

\begin{align*} \frac{dx}{da}&=\frac{vCos(a)}{g}\left[vCos(a)+ 1/2\left(v^2Sin^2(a)+2gy_0)^{-1/2}(2v^2Sin(a)Cos(a))\right)\right] \\ &-\left[vSin(a)+\left(v^2Sin^2(a)+2gy_0\right)^{1/2}\right]\frac{vSin(a)}{g} \end{align}

That's just the chain rule and the basic rules for differentiation for sine and cosine and other functions.

Setting that to zero and solving for a, gives an extremum which could be a maximum or minimum. However that looks difficult to solve for.

However, this does not address the specific application you're working on (like shooting a projectile in the air with an initial velocity v, initial height y0, and angle a), and then determining the angle which gives the greatest distance. Not sure though this equation could be applied to that setup.

Last edited: Dec 28, 2005
7. Dec 28, 2005

### arildno

To OP:
Derivatives WITH RESPECT TO WHAT?? With respect to the equality sign, perhaps?

You have to learn to state your problems precisely, otherwise you'll end up not understanding them properly.


text:
34 篇文章 0 订阅

# Tutorial 33: RichEdit Control: Basics

There are lots of request on tutorials about RichEdit controls. Finally I have played with it enough to think I can write tutorials about it. So here it is: the first RichEdit tutorial. The tutorials will describe nearly everything there is to know about RichEdit control or at least as much as I know it. The amount of information is rather large so I divide it into several parts, this tutorial being the first part. In this tutorial, you'll learn what a RichEdit control is, how to create it and how to load/save data to/from it.

### Theory

A richedit control can be thought of as a souped-up edit control. It provides many desirable features that are lacking from the plain simple edit control, for example, the ability to use multiple font face/size, multiple-level undo/redo, search-for-text operation, OLE-embedded objects, drag-and-drop editing support, etc. Since the richedit control has so many features, it's stored in a separate DLL. This also means that, to use it, you can't just call InitCommonControls like other common controls. You have to call LoadLibrary to load the richedit DLL.

The problem is that there are three versions of richedit control up till now. Version 1,2, and 3. The table below shows you the name of the DLL for each version.

DLL NameRichEdit versionRichedit Class Name
Riched32.dll1.0RICHEDIT
RichEd20.dll2.0RICHEDIT20A
RichEd20.dll3.0RICHEDIT20A

You can notice that richedit version 2 and 3 use the same DLL name. They also use the same class name! This can pose a problem if you want to use specific features of richedit 3.0. Up to now, I haven't found an official method of differentiating between version 2.0 and 3.0. However, there is a workaround which works ok, I'll show you later.

.data
RichEditDLL db "RichEd20.dll",0	......data?	hRichEditDLL dd ?.code	invoke LoadLibrary,addr RichEditDLL	mov hRichEditDLL,eax	......	invoke FreeLibrary,hRichEditDLL

When the richedit dll is loaded, it registers the RichEdit window class. Thus it's imperative that you load the DLL before you create the control. The names of the richedit control classes are also different. Now you may have a question: how do I know which version of richedit control should I use? Using the latest version is not always appropriate if you don't require the extra features. So below is the table that shows the features provided by each version of richedit control.

FeatureVersion 1.0Version 2.0Version 3.0
selection bar
x
x
x
unicode editing
x
x
character/paragraph formatting
x
x
x
search for text
forward
forward/backward
forward/backward
OLE embedding
x
x
x
Drag and drop editing
x
x
x
Undo/Redo
single-level
multi-level
multi-level
automatic URL recognition
x
x
Accelerator key support
x
x
Windowless operation
x
x
Line break
CRLF
CR only
CR only (can emulate version 1.0)
Zoom
x
Paragraph numbering
x
simple table
x
x
underline coloring
x
hidden text
x
font binding
x

The above table is by no means comprehensive: I only list the important features.

### Creating the richedit control

After loading the richedit dll, you can call CreateWindowEx to create the control. You can use edit control styles and common window styles in CreateWindowEx except ES_LOWERCASE, ES_UPPERCASE and ES_OEMCONVERT.

.const
RichEditID equ 300
.data
RichEditDLL db "RichEd20.dll",0	RichEditClass db "RichEdit20A",0
...
.data?	hRichEditDLL dd ?
hwndRichEdit dd ?
.code
.....
mov hRichEditDLL,eax	invoke CreateWindowEx,0,addr RichEditClass,WS_VISIBLE or ES_MULTILINE or WS_CHILD or WS_VSCROLL or WS_HSCROLL, 										CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,CW_USEDEFAULT,hWnd,RichEditID,hInstance,0
mov hwndRichEdit,eax

### Setting default text and background color

You may have the problem with setting text color and the background color of the edit control. But this problem has been remedy in richedit control. To set the background color of the richedit control, you send EM_SETBKGNDCOLOR to the richedit control. This message has the following syntax.

wParam == color option. The value of 0 in this parameter specifies that Windows uses the color value in lParam as the background color. If this value is nonzero, Windows uses the Windows system background color. Since we send this message to change the background color, we must pass 0 in wParam.
lParam == specifies the COLORREF structure of the color you want to set if wParam is 0.

For example, if I want to set the background color to pure blue, I would issue this following line:

		invoke SendMessage,hwndRichEdit,EM_SETBKGNDCOLOR,0,0FF0000h

To set the text color, richedit control provides another new message, EM_SETCHARFORMAT, for the job. This message controls the text formatting of a range to characters in selection or all text in the control. This message has the following syntax:

wParam == formatting options:

 SCF_ALL The operation affects all text in the control. SCF_SELECTION The operation affects only the text in selection SCF_WORD or SCF_SELECTION Affects the word in selection. If the selection is empy, ie, only the caret is in the word, the operation affects that word. SCF_WORD flag must be used with SCF_SELECTION.

lParam == pointer to a CHARFORMAT or CHARFORMAT2 structure that specifies the text formatting to be applied. CHARFORMAT2 is available for richedit 2.0 and above only. This doesn't mean that you must use CHARFORMAT2 with RichEdit 2.0 or above. You can still use CHARFORMAT if the added features in CHARFORMAT2 are not necessary for your need.

CHARFORMATA STRUCT
cbSize DWORD ?
dwEffects DWORD    ?
yHeight DWORD ?
yOffset DWORD ?
crTextColor COLORREF ?
bCharSet BYTE ?
bPitchAndFamily    BYTE ?
szFaceName BYTE LF_FACESIZE dup(?)
CHARFORMATA ENDS

Field NameDescription
cbSizeThe size of the structure. RichEdit control uses this field to determine the version of the structure whether it is CHARFORMAT or CHARFORMAT2

Bit flags that determine which of the following members are valid.

 CFM_BOLD The CFE_BOLD value of the dwEffects member is valid CFM_CHARSET The bCharSet member is valid. CFM_COLOR The crTextColor member and the CFE_AUTOCOLOR value of the dwEffects member are valid CFM_FACE The szFaceName member is valid. CFM_ITALIC The CFE_ITALIC value of the dwEffects member is valid CFM_OFFSET The yOffset member is valid CFM_PROTECTED The CFE_PROTECTED value of the dwEffects member is valid CFM_SIZE The yHeight member is valid CFM_STRIKEOUT The CFE_STRIKEOUT value of the dwEffects member is valid. CFM_UNDERLINE The CFE_UNDERLINE value of the dwEffects member is valid
dwEffects

The character effects. Can be the combination of the following values

 CFE_AUTOCOLOR Use the system text color CFE_BOLD Characters are bold CFE_ITALIC Characters are italic CFE_STRIKEOUT Characters are struck. CFE_UNDERLINE Characters are underlined CFE_PROTECTED Characters are protected; an attempt to modify them will cause an EN_PROTECTED notification message.
yHeightCharacter height, in twips (1/1440 of an inch or 1/20 of a printer's point).
yOffsetCharacter offset, in twips, from the baseline. If the value of this member is positive, the character is a superscript; if it is negative, the character is a subscript.
crTextColor Text color. This member is ignored if the CFE_AUTOCOLOR character effect is specified.
bCharSetCharacter set value
bPitchAndFamilyFont family and pitch.
szFaceName Null-terminated character array specifying the font name

From examination of the structure, you'll see that we can change the text effects (bold,italic, strikeout,underline), text color (crTextColor) and font face/size/character set. A notable flag is CFE_RPOTECTED. The text with this flag is marked as protected which means that when the user tries to modify it, EN_PROTECTED notification message will be sent to the parent window. And you can allow the change to happen or not.

CHARFORMAT2 adds more text styles such as font weight, spacing,text background color, kerning, etc. If you don't need these extra features, simply use CHARFORMAT.

To set text formatting, you have to think about the range of text you want to apply to. Richedit control introduces the notion of character text range. Richedit control gives each character a number starting from 0: the first characterin the control has Id of 0, the second character 1 and so on. To specify a text range, you must give the richedit control two numbers: the IDs of the first and the last character of the range. To apply the text formatting with EM_SETCHARFORMAT, you have at most three choices:

1. Apply to all text in the control (SCF_ALL)
2. Apply to the text currently in selection (SCF_SELECTION)
3. Apply to the whole word currently in selection (SCF_WORD or SCF_SELECTION)

The first and the second choices are straightforward. The last choice requires a little explanation. If the current selection only covers one or more of the characters in the word but not the whole word, specifying the flag SCF_WORD+SCF_SELECTION applies the text formatting to the whole word. Even if there is no current selection, ie, only the caret is positioned in the word, the third choice also applies the text formatting to the whole word.

To use EM_SETCHARFORMAT, you need to fill several members of CHARFORMAT (or CHARFORMAT2) structure. For example, if we want to set the text color, we will fill the CHARFORMAT structure as follows:

.data?
cf CHARFORMAT <>
....
.code
mov cf.cbSize,sizeof cf
mov cf.crTextColor,0FF0000h
invoke SendMessage,hwndRichEdit,EM_SETCHARFORMAT,SCF_ALL,addr cf

The above code snippet sets the text color of the richedit control to pure blue. Note that if there is no text in the richedit control when EM_SETCHARFORMAT is issued, the text entered into the richedit control following the message will use the text formatting specified by the EM_SETCHARFORMAT message.

### Setting the text/saving the text

For those of you who are used to edit control, you'll surely be familiar with WM_GETTEXT/WM_SETTEXT as the means to set the text/get the text to/from the control. This method still works with richedit control but may not be efficient if the file is large. Edit control limits the text that can be entered into it to 64K but richedit control can accept text much larger than that. It would be very cumbersome to allocate a very large block of memory (such as 10 MB or so) to receive the text from WM_GETTEXT. Richedit control offers a new approach to this method, ie. text streaming.

To put it simply, you provide the address of a callback function to the richedit control. And richedit control will call that callback, passing the address of the buffer to it, when it's ready. The callback will fill the buffer with the data it wants to send to the control or read the data from the buffer and then waits for the next call until the operation is finished. This paradigm is used for both streaming in (setting the text) and streaming out (getting the text out of the control). You'll see that this method is more efficient: the buffer is provided by the richedit control itself so the data are divided into chunks. The operations involve two messages: EM_STREAMIN and EM_STREAMOUT

Both EM_STREAMIN and EM_STREAMOUT use the same syntax:

wParam == formatting options.

 SF_RTF The data is in the rich-text format (RTF) SF_TEXT The data is in the plain text format SFF_PLAINRTF Only the keywords common to all languages are streamed in. SFF_SELECTION If specified, the target of the operation is the text currently in selection. If you stream the text in, the text replaces the current selection. If you stream the text out, only the text currently in selection is streamed out. If this flag is not specified, the operation affects the whole text in the control. SF_UNICODE (Available on RichEdit 2.0 or later) Specify the unicode text.

lParam == point to an EDITSTREAM structure which has the following definition:

 EDITSTREAM STRUCT
dwError DWORD ?
pfnCallback DWORD ?
EDITSTREAM ENDS

 dwCookie application-defined value that will be passed to the callback function speficied in pfnCallback member below. We normally pass some important value to the callback function such as the file handle to use in the stream-in/out procedure. dwError Indicates the results of the stream-in (read) or stream-out (write) operation. A value of zero indicates no error. A nonzero value can be the return value of the EditStreamCallback function or a code indicating that the control encountered an error. pfnCallback Pointer to an EditStreamCallback function, which is an application-defined function that the control calls to transfer data. The control calls the callback function repeatedly, transferring a portion of the data with each call

The editstream callback function has the following definition:

	EditStreamCallback proto dwCookie:DWORD,				 pBuffer:DWORD,
NumBytes:DWORD,
pBytesTransferred:DWORD

You have to create a function with the above prototype in your program. And then pass its address to EM_STREAMIN or EM_STREAMOUT via EDITSTREAM structure.

For stream-in operation (settting the text in the richedit control):

	dwCookie: the application-defined value you pass to EM_STREAMIN via EDITSTREAM structure. We almost always
pass the file handle of the file we want to set its content to the control here.
pBuffer: points to the buffer provided by the richedit control that will receive the text from your callback function.
NumBytes: the maximum number of bytes you can write the the buffer (pBuffer) in this call. You MUST always obey this limit, ie, you can send
less data than the value in NumBytes but must not send more data than this value. You can think of this value as the size
of the buffer in pBuffer.
pBytesTransferred: points to a dword that you must set the value indicating the number of bytes you actually transferred to the buffer.
This value is usually identical to the value in NumBytes. The exception is when the data is to send is less than
the size of the buffer provided such as when the end of file is reached.

For stream-out operation (getting the text out of the richedit control):

	dwCookie: Same as the stream-in operation. We usually pass the file handle we want to write the data to in this parameter.
pBuffer: points to the buffer provided by the richedit control that is filled with the data from the richedit control.
To obtain its size, you must examine the value of NumBytes.
NumBytes: the size of the data in the buffer pointed to by pBuffer.
pBytesTransferred: points to a dword that you must set the value indicating the number of bytes you actually read from the buffer.

The callback function returns 0 to indicate success and richedit control will continue calling the callback function if there is still data left to read/write. If some error occurs during the process and you want to stop the operation, returns a non-zero value and the richedit control will discard the data pointed to by pBuffer. The error/success value will be filled in the dwError field of EDITSTREAM so you can examine the error/success status of the stream operation after SendMessage returns.

### Example:

The example below is a simple editor which you can open an asm source code file, edit and save it. It uses RichEdit control version 2.0 or above.

.386
.model flat,stdcall
option casemap:none
include /masm32/include/windows.inc
include /masm32/include/user32.inc
include /masm32/include/comdlg32.inc
include /masm32/include/gdi32.inc
include /masm32/include/kernel32.inc
includelib /masm32/lib/gdi32.lib
includelib /masm32/lib/comdlg32.lib
includelib /masm32/lib/user32.lib
includelib /masm32/lib/kernel32.lib

WinMain proto :DWORD,:DWORD,:DWORD,:DWORD

.const
IDM_OPEN                      equ  40001
IDM_SAVE                       equ 40002
IDM_CLOSE                      equ 40003
IDM_SAVEAS                     equ 40004
IDM_EXIT                       equ 40005
IDM_COPY                      equ  40006
IDM_CUT                       equ  40007
IDM_PASTE                      equ 40008
IDM_DELETE                     equ 40009
IDM_SELECTALL                  equ 40010
IDM_OPTION 			equ 40011
IDM_UNDO			equ 40012
IDM_REDO			equ 40013
IDD_OPTIONDLG                  equ 101
IDC_BACKCOLORBOX               equ 1000
IDC_TEXTCOLORBOX               equ 1001

RichEditID 			equ 300

.data
ClassName db "IczEditClass",0
AppName  db "IczEdit version 1.0",0
RichEditDLL db "riched20.dll",0
RichEditClass db "RichEdit20A",0
NoRichEdit db "Cannot find riched20.dll",0
ASMFilterString 		db "ASM Source code (*.asm)",0,"*.asm",0
db "All Files (*.*)",0,"*.*",0,0
OpenFileFail db "Cannot open the file",0
WannaSave db "The data in the control is modified. Want to save it?",0
FileOpened dd FALSE
BackgroundColor dd 0FFFFFFh		; default to white
TextColor dd 0		; default to black

.data?
hInstance dd ?
hRichEdit dd ?
hwndRichEdit dd ?
FileName db 256 dup(?)
AlternateFileName db 256 dup(?)
CustomColors dd 16 dup(?)

.code
start:
invoke GetModuleHandle, NULL
mov    hInstance,eax
.if eax!=0
mov hRichEdit,eax
invoke WinMain, hInstance,0,0, SW_SHOWDEFAULT
invoke FreeLibrary,hRichEdit
.else
.endif
invoke ExitProcess,eax

WinMain proc hInst:DWORD,hPrevInst:DWORD,CmdLine:DWORD,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:DWORD
mov   wc.cbSize,SIZEOF WNDCLASSEX
mov   wc.style, CS_HREDRAW or CS_VREDRAW
mov   wc.lpfnWndProc, OFFSET WndProc
mov   wc.cbClsExtra,NULL
mov   wc.cbWndExtra,NULL
push  hInst
pop   wc.hInstance
mov   wc.hbrBackground,COLOR_WINDOW+1
mov   wc.lpszClassName,OFFSET ClassName
mov   wc.hIcon,eax
mov   wc.hIconSm,eax
mov   wc.hCursor,eax
mov   hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
.break .if (!eax)
.endw
mov   eax,msg.wParam
ret
WinMain endp

xor eax,1
ret
StreamInProc endp

StreamOutProc proc hFile:DWORD,pBuffer:DWORD, NumBytes:DWORD, pBytesWritten:DWORD
invoke WriteFile,hFile,pBuffer,NumBytes,pBytesWritten,0
xor eax,1
ret
StreamOutProc endp

CheckModifyState proc hWnd:DWORD
invoke SendMessage,hwndRichEdit,EM_GETMODIFY,0,0
.if eax!=0
.if eax==IDYES
invoke SendMessage,hWnd,WM_COMMAND,IDM_SAVE,0
.elseif eax==IDCANCEL
mov eax,FALSE
ret
.endif
.endif
mov eax,TRUE
ret
CheckModifyState endp

SetColor proc
LOCAL cfm:CHARFORMAT
invoke SendMessage,hwndRichEdit,EM_SETBKGNDCOLOR,0,BackgroundColor
mov cfm.cbSize,sizeof cfm
push TextColor
pop cfm.crTextColor
ret
SetColor endp

OptionProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
LOCAL clr:CHOOSECOLOR
.if uMsg==WM_INITDIALOG
.elseif uMsg==WM_COMMAND
mov eax,wParam
shr eax,16
.if ax==BN_CLICKED
mov eax,wParam
.if ax==IDCANCEL
invoke SendMessage,hWnd,WM_CLOSE,0,0
.elseif ax==IDC_BACKCOLORBOX
mov clr.lStructSize,sizeof clr
push hWnd
pop clr.hwndOwner
push hInstance
pop clr.hInstance
push BackgroundColor
pop clr.rgbResult
mov clr.lpCustColors,offset CustomColors
mov clr.Flags,CC_ANYCOLOR or CC_RGBINIT
.if eax!=0
push clr.rgbResult
pop BackgroundColor
invoke GetDlgItem,hWnd,IDC_BACKCOLORBOX
invoke InvalidateRect,eax,0,TRUE
.endif
.elseif ax==IDC_TEXTCOLORBOX
mov clr.lStructSize,sizeof clr
push hWnd
pop clr.hwndOwner
push hInstance
pop clr.hInstance
push TextColor
pop clr.rgbResult
mov clr.lpCustColors,offset CustomColors
mov clr.Flags,CC_ANYCOLOR or CC_RGBINIT
.if eax!=0
push clr.rgbResult
pop TextColor
invoke GetDlgItem,hWnd,IDC_TEXTCOLORBOX
invoke InvalidateRect,eax,0,TRUE
.endif
.elseif ax==IDOK
;==================================================================================
; Save the modify state of the richedit control because changing the text color changes the
; modify state of the richedit control.
;==================================================================================
invoke SendMessage,hwndRichEdit,EM_GETMODIFY,0,0
push eax
invoke SetColor
pop eax
invoke SendMessage,hwndRichEdit,EM_SETMODIFY,eax,0
invoke EndDialog,hWnd,0
.endif
.endif
.elseif uMsg==WM_CTLCOLORSTATIC
invoke GetDlgItem,hWnd,IDC_BACKCOLORBOX
.if eax==lParam
invoke CreateSolidBrush,BackgroundColor
ret
.else
invoke GetDlgItem,hWnd,IDC_TEXTCOLORBOX
.if eax==lParam
invoke CreateSolidBrush,TextColor
ret
.endif
.endif
mov eax,FALSE
ret
.elseif uMsg==WM_CLOSE
invoke EndDialog,hWnd,0
.else
mov eax,FALSE
ret
.endif
mov eax,TRUE
ret
OptionProc endp

WndProc proc hWnd:DWORD, uMsg:DWORD, wParam:DWORD, lParam:DWORD
LOCAL chrg:CHARRANGE
LOCAL ofn:OPENFILENAME
LOCAL buffer[256]:BYTE
LOCAL editstream:EDITSTREAM
LOCAL hFile:DWORD
.if uMsg==WM_CREATE
invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr RichEditClass,0,WS_CHILD or WS_VISIBLE or ES_MULTILINE or WS_VSCROLL or WS_HSCROLL or ES_NOHIDESEL,				CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,hWnd,RichEditID,hInstance,0
mov hwndRichEdit,eax
;=============================================================
; Set the text limit. The default is 64K
;=============================================================
invoke SendMessage,hwndRichEdit,EM_LIMITTEXT,-1,0
;=============================================================
; Set the default text/background color
;=============================================================
invoke SetColor
invoke SendMessage,hwndRichEdit,EM_SETMODIFY,FALSE,0
invoke SendMessage,hwndRichEdit,EM_EMPTYUNDOBUFFER,0,0
mov eax,lParam
.if FileOpened==TRUE	; a file is already opened
.else
.endif
;=============================================================================
; Check whether there is some text in the clipboard. If so, we enable the paste menuitem
;=============================================================================
invoke SendMessage,hwndRichEdit,EM_CANPASTE,CF_TEXT,0
.if eax==0		; no text in the clipboard
.else
.endif
;==========================================================
; check whether the undo queue is empty
;==========================================================
invoke SendMessage,hwndRichEdit,EM_CANUNDO,0,0
.if eax==0
.else
.endif
;=========================================================
; check whether the redo queue is empty
;=========================================================
invoke SendMessage,hwndRichEdit,EM_CANREDO,0,0
.if eax==0
.else
.endif
;=========================================================
; check whether there is a current selection in the richedit control.
; If there is, we enable the cut/copy/delete menuitem
;=========================================================
mov eax,chrg.cpMin
.if eax==chrg.cpMax		; no current selection
.else
.endif
.endif
.elseif uMsg==WM_COMMAND
mov eax,wParam
.if ax==IDM_OPEN
mov ofn.lStructSize,sizeof ofn
push hWnd
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter,offset ASMFilterString
mov ofn.lpstrFile,offset FileName
mov byte ptr [FileName],0
mov ofn.nMaxFile,sizeof FileName
mov ofn.Flags,OFN_FILEMUSTEXIST or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST
.if eax!=0
.if eax!=INVALID_HANDLE_VALUE
mov hFile,eax
;================================================================
; stream the text into the richedit control
;================================================================
mov editstream.pfnCallback,offset StreamInProc
;==========================================================
; Initialize the modify state to false
;==========================================================
invoke SendMessage,hwndRichEdit,EM_SETMODIFY,FALSE,0
invoke CloseHandle,hFile
mov FileOpened,TRUE
.else
.endif
.endif
.elseif ax==IDM_CLOSE
invoke CheckModifyState,hWnd
.if eax==TRUE
invoke SetWindowText,hwndRichEdit,0
mov FileOpened,FALSE
.endif
.elseif ax==IDM_SAVE
.if eax!=INVALID_HANDLE_VALUE
@@:
mov hFile,eax
;================================================================
; stream the text to the file
;================================================================
mov editstream.pfnCallback,offset StreamOutProc
;==========================================================
; Initialize the modify state to false
;==========================================================
invoke SendMessage,hwndRichEdit,EM_SETMODIFY,FALSE,0
invoke CloseHandle,hFile
.else
.endif
.elseif ax==IDM_COPY
invoke SendMessage,hwndRichEdit,WM_COPY,0,0
.elseif ax==IDM_CUT
invoke SendMessage,hwndRichEdit,WM_CUT,0,0
.elseif ax==IDM_PASTE
invoke SendMessage,hwndRichEdit,WM_PASTE,0,0
.elseif ax==IDM_DELETE
invoke SendMessage,hwndRichEdit,EM_REPLACESEL,TRUE,0
.elseif ax==IDM_SELECTALL
mov chrg.cpMin,0
mov chrg.cpMax,-1
.elseif ax==IDM_UNDO
invoke SendMessage,hwndRichEdit,EM_UNDO,0,0
.elseif ax==IDM_REDO
invoke SendMessage,hwndRichEdit,EM_REDO,0,0
.elseif ax==IDM_OPTION
.elseif ax==IDM_SAVEAS
mov ofn.lStructSize,sizeof ofn
push hWnd
pop ofn.hwndOwner
push hInstance
pop ofn.hInstance
mov ofn.lpstrFilter,offset ASMFilterString
mov ofn.lpstrFile,offset AlternateFileName
mov byte ptr [AlternateFileName],0
mov ofn.nMaxFile,sizeof AlternateFileName
mov ofn.Flags,OFN_FILEMUSTEXIST or OFN_HIDEREADONLY or OFN_PATHMUSTEXIST
.if eax!=0
.if eax!=INVALID_HANDLE_VALUE
jmp @B
.endif
.endif
.elseif ax==IDM_EXIT
invoke SendMessage,hWnd,WM_CLOSE,0,0
.endif
.endif
.elseif uMsg==WM_CLOSE
invoke CheckModifyState,hWnd
.if eax==TRUE
invoke DestroyWindow,hWnd
.endif
.elseif uMsg==WM_SIZE
mov eax,lParam
mov edx,eax
and eax,0FFFFh
shr edx,16
invoke MoveWindow,hwndRichEdit,0,0,eax,edx,TRUE
.elseif uMsg==WM_DESTROY
invoke PostQuitMessage,NULL
.else
invoke DefWindowProc,hWnd,uMsg,wParam,lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start

;===================================================================
; The resource file
;===================================================================
#include "resource.h"
#define IDD_OPTIONDLG                   101
#define IDC_BACKCOLORBOX                1000
#define IDC_TEXTCOLORBOX                1001
#define IDM_OPEN                        40001
#define IDM_SAVE                        40002
#define IDM_CLOSE                       40003
#define IDM_SAVEAS                      40004
#define IDM_EXIT                        40005
#define IDM_COPY                        40006
#define IDM_CUT                         40007
#define IDM_PASTE                       40008
#define IDM_DELETE                      40009
#define IDM_SELECTALL                   40010
#define IDM_OPTION                      40011
#define IDM_UNDO                        40012
#define IDM_REDO                        40013

BEGIN
POPUP "&File"
BEGIN
END
POPUP "&Edit"
BEGIN
END
END

IDD_OPTIONDLG DIALOG DISCARDABLE  0, 0, 183, 54
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU | DS_CENTER
CAPTION "Options"
FONT 8, "MS Sans Serif"
BEGIN
DEFPUSHBUTTON   "OK",IDOK,137,7,39,14
PUSHBUTTON      "Cancel",IDCANCEL,137,25,39,14
GROUPBOX        "",IDC_STATIC,5,0,124,49
LTEXT           "Background Color:",IDC_STATIC,20,14,60,8
LTEXT           "",IDC_BACKCOLORBOX,85,11,28,14,SS_NOTIFY | WS_BORDER
LTEXT           "Text Color:",IDC_STATIC,20,33,35,8
LTEXT           "",IDC_TEXTCOLORBOX,85,29,28,14,SS_NOTIFY | WS_BORDER
END

### Analysis:

The program first loads the richedit dll, which in this case is riched20.dll. If the dll cannot be loaded, it exits to Windows.

invoke LoadLibrary,addr RichEditDLL
.if eax!=0
mov hRichEdit,eax
invoke WinMain,hInstance,0,0, SW_SHOWDEFAULT
invoke FreeLibrary,hRichEdit
.else
.endif
invoke ExitProcess,eax

After the dll is loaded successfully, we proceed to create a normal window which will be the parent of the richedit control. Within the WM_CREATE handler, we create the richedit control:

		invoke CreateWindowEx,WS_EX_CLIENTEDGE,addr RichEditClass,0,WS_CHILD or WS_VISIBLE or ES_MULTILINE or WS_VSCROLL or WS_HSCROLL or ES_NOHIDESEL,				CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,hWnd,RichEditID,hInstance,0
mov hwndRichEdit,eax

Note that we specify ES_MULTILINE style else the control will be a single-lined one.

		invoke SendMessage,hwndRichEdit,EM_LIMITTEXT,-1,0

After the richedit control is created, we must set the new text limit on it. By default, the richedit control has 64K text limit, the same as a simple multi-line edit control. We must extend this limit to allow it to operate with larger files. In the above line, I specify -1 which amounts to 0FFFFFFFFh, a very large value.

       invoke SetColor

Next, we set the text/background color. Since this operation can be performed in other part of the program, I put the code in a function named SetColor.

SetColor proc
LOCAL cfm:CHARFORMAT
invoke SendMessage,hwndRichEdit,EM_SETBKGNDCOLOR,0,BackgroundColor

Setting the background color of the richedit control is a straightforward operation: just send EM_SETBKGNDCOLOR message to the richedit control. (If you use a multi-line edit control, you have to process WM_CTLCOLOREDIT). The default background color is white.

	invoke RtlZeroMemory,addr cfm,sizeof cfm
mov cfm.cbSize,sizeof cfm
push TextColor
pop cfm.crTextColor

After the background color is set, we fill in the members of CHARFORMAT in order to set the text color. Note that we fill cbSize with the size of the structure so the richedit control knows we are sending it CHARFORMAT, not CHARFORMAT2. dwMask has only one flag, CFM_COLOR, because we only want to set the text color and crTextColor is filled with the value of the desired text color.

	invoke SendMessage,hwndRichEdit,EM_SETCHARFORMAT,SCF_ALL,addr cfm
ret
SetColor endp

After settting the color, you have to empty undo buffer simply because the act of changing text/background color is undo-able. We send EM_EMPTYUNDOBUFFER message to achieve this.

	invoke SendMessage,hwndRichEdit,EM_EMPTYUNDOBUFFER,0,0

After filling the CHARFORMAT structure, we send EM_SETCHARFORMAT to the richedit control, specifying SCF_ALL flag in wParam to indicate that we want the text formatting to be applied to all text in the control.

Note that when we first created the richedit control, we didn't specify its size/position at that time. That's because we want it to cover the whole client area of the parent window. We resize it whenever the size of the parent window changes.

	.elseif uMsg==WM_SIZE
mov eax,lParam
mov edx,eax
and eax,0FFFFh
shr edx,16
invoke MoveWindow,hwndRichEdit,0,0,eax,edx,TRUE

In the above code snippet, we use the new dimension of the client area passed in lParam to resize the richedit control with MoveWindow.

When the user clicks on the File/Edit menu bar, we process WM_INITPOPUPMENU so that we can prepare the states of the menuitems in the submenu before displaying it to the user. For example, if a file is already opened in the richedit control, we want to disable the open menuitem and enable all the remaining menuitems.

In the case of the File menu bar, we use the variable FileOpened as the flag to determine whether a file is already opened. If the value in this variable is TRUE, we know that a file is already opened.

	.elseif uMsg==WM_INITMENUPOPUP
mov eax,lParam
.if FileOpened==TRUE	; a file is already opened
.else
.endif

As you can see, if a file is already opened, we gray out the open menuitem and enable the remaining menuitems. The reverse is true of FileOpened is false.

In the case of the edit menu bar, we need to check the state of the richedit control/clipboard first.

			invoke SendMessage,hwndRichEdit,EM_CANPASTE,CF_TEXT,0
.if eax==0		; no text in the clipboard
.else
.endif

We first check whether some text is available in the clipboard by sending EM_CANPASTE message. If some text is available, SendMessage returns TRUE and we enable the paste menuitem. If not, we gray out the menuitem.

			invoke SendMessage,hwndRichEdit,EM_CANUNDO,0,0
.if eax==0
.else
.endif

Next, we check whether the undo buffer is empty by sending EM_CANUNDO message. If it's not empty, SendMessage returns TRUE and we enable the undo menuitem.

			invoke SendMessage,hwndRichEdit,EM_CANREDO,0,0
.if eax==0
.else
.endif

We check the redo buffer by sending EM_CANREDO message to the richedit control. If it's not empty, SendMessage returns TRUE and we enable the redo menuitem.

			invoke SendMessage,hwndRichEdit,EM_EXGETSEL,0,addr chrg
mov eax,chrg.cpMin
.if eax==chrg.cpMax		; no current selection
.else
.endif

Lastly, we check whether a current selection exists by sending EM_EXGETSEL message. This message uses a CHARRANGE structure which is defined as follows:

CHARRANGE STRUCT
cpMin  DWORD      ?
cpMax  DWORD      ?
CHARRANGE ENDS

cpMin contains the character position index immediately preceding the first character in the range.
cpMax contains the character position immediately following the last character in the range.

After EM_EXGETSEL returns, the CHARRANGE structure is filled with the starting-ending character position indices of the selection range. If there is no current selection, cpMin and cpMax are identical and we gray out the cut/copy/delete menuitems.

When the user clicks the Open menuitem, we display an open file dialog box and if the user selects a file, we open the file and stream its content to the richedit control.

					invoke CreateFile,addr FileName,GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,0
.if eax!=INVALID_HANDLE_VALUE
mov hFile,eax

mov editstream.pfnCallback,offset StreamInProc
invoke SendMessage,hwndRichEdit,EM_STREAMIN,SF_TEXT,addr editstream

After the file is successfully opened with CreateFile, we fill the EDITSTREAM structure in preparation for EM_STREAMIN message. We choose to send the handle to the opened file via dwCookie member and pass the address of the stream callback function in pfnCallback.

The stream callback procedure itself is the essence of simplicity.

StreamInProc proc hFile:DWORD,pBuffer:DWORD, NumBytes:DWORD, pBytesRead:DWORD
xor eax,1
ret
StreamInProc endp

You can see that all parameters of the stream callback procedure fit perfectly with ReadFile. And the return value of ReadFile is xor-ed with 1 so that if it returns 1 (success), the actual value returned in eax is 0 and vice versa.

	invoke SendMessage,hwndRichEdit,EM_SETMODIFY,FALSE,0
invoke CloseHandle,hFile
mov FileOpened,TRUE

After EM_STREAMIN returns, it means the stream operation is completed. In reality, we must check the value of dwError member of the EDITSTREAM structure.

Richedit (and edit) control supports a flag to indicate whether its content is modified. We can obtain the value of this flag by sending EM_GETMODIFY message to the control. SendMessage returns TRUE if the content of the control was modified. Since we stream the text into the control, it's a kind of a modification. We must set the modify flag to FALSE by sending EM_SETMODIFY with wParam==FALSE to the control to start anew after the stream-in opertion is finished. We immediately close the file and set FileOpened to TRUE to indicate that a file was opened.

When the user clicks on save/saveas menuitem, we use EM_STREAMOUT message to output the content of the richedit control to a file. As with the streamin callback function, the stream-out callback function is simplicity in itself. It fits perfectly with WriteFile.

The text operations such as cut/copy/paste/redo/undo are easily implemented by sending single message to the richedit control, WM_CUT/WM_COPY/WM_PASTE/WM_REDO/WM_UNDO respectively.

The delete/select all operations are done as follows:

			.elseif ax==IDM_DELETE
invoke SendMessage,hwndRichEdit,EM_REPLACESEL,TRUE,0
.elseif ax==IDM_SELECTALL
mov chrg.cpMin,0
mov chrg.cpMax,-1
invoke SendMessage,hwndRichEdit,EM_EXSETSEL,0,addr chrg

The delete operation affects the currently selection. I send EM_REPLACESEL message with NULL string so the richedit control will replace the currently selected text with the null string.

The select-all operation is done by sending EM_EXSETSEL message, specifying cpMin==0 and cpMax==-1 which amounts to selecting all the text.

When the user selects Option menu bar, we display a dialog box presenting the current background/text colors.

When the user clicks on one of the color boxes, it displays the choose-color dialog box. The "color box" is in fact a static control with SS_NOTIFY and WS_BORDER flag. A static control with SS_NOTIFY flag will notify its parent window with mouse actions on it, such as BN_CLICKED (STN_CLICKED). That's the trick.

			.elseif ax==IDC_BACKCOLORBOX
mov clr.lStructSize,sizeof clr
push hWnd
pop clr.hwndOwner
push hInstance
pop clr.hInstance
push BackgroundColor
pop clr.rgbResult
mov clr.lpCustColors,offset CustomColors
mov clr.Flags,CC_ANYCOLOR or CC_RGBINIT
.if eax!=0
push clr.rgbResult
pop BackgroundColor
invoke GetDlgItem,hWnd,IDC_BACKCOLORBOX
invoke InvalidateRect,eax,0,TRUE
.endif

When the user clicks on one of the color box, we fill the members of the CHOOSECOLOR structure and call ChooseColor to display the choose-color dialog box. If the user selects a color, the colorref value is returned in rgbResult member and we store that value in BackgroundColor variable. After that, we force a repaint on the color box by calling InvalidateRect on the handle to the color box. The color box sends WM_CTLCOLORSTATIC message to its parent window.

		invoke GetDlgItem,hWnd,IDC_BACKCOLORBOX
.if eax==lParam
invoke CreateSolidBrush,BackgroundColor
ret

Within the WM_CTLCOLORSTATIC handler, we compare the handle of the static control passed in lParam to that of both the color boxes. If the values match, we create a new brush using the color in the variable and immediately return. The static control will use the newly created brush to paint its background.

• 0
点赞
• 0
收藏
• 打赏
• 0
评论
12-08 1992
10-08 1358
11-15 37
12-09 37
05-03 44
12-09 39
10-31 53
10-31 30
12-09 43
12-09 34
12-09 33
12-09 32
12-09 56
05-03 41
05-03 37
05-03 55
12-09 49

### “相关推荐”对你有帮助么？

• 非常没帮助
• 没帮助
• 一般
• 有帮助
• 非常有帮助

jimgreen

¥2 ¥4 ¥6 ¥10 ¥20

1.余额是钱包充值的虚拟货币，按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载，可以购买VIP、C币套餐、付费专栏及课程。


text:
# Revision history [back]

Testing your node shows two issues. Firstly:

AnglePublisher.py", line 18, in timer_callback
msg.data = [(20.0,20.0,320.0.i,20.0)]
AttributeError: 'float' object has no attribute 'i'

Assuming that's a typo :) removing the .i results in your real issue:

AnglePublisher.py", line 18, in timer_callback
msg.data = [(20.0,20.0,320.0,20.0)]
File "/opt/ros/foxy/lib/python3.8/site-packages/std_msgs/msg/_float64_multi_array.py", line 156, in data
assert \
AssertionError: The 'data' field must be a set or sequence and each value of type 'float'

As seen in the documentation of Float64MultiArray linked by @Spectre, the data member is a 1-dimensional array, whereas you assign a list with a tuple to it, which is akin to a 2D array. The normal way to use a MultiArray message is to flatten your data to a single array, and then to specify the original layout in the layout member, also mentioned by @Spectre.

However this is not a hard requirement. If you only ever send 4 values, and your subscribers will always expect just that, you could just send them as a flat array and ignore the layout member on both sides:

msg.data = [20.0,20.0,320.0,20.0]

If however you really want to send 'multi arrays', as in lists of multiple tuples/nested lists, and you want to make your node generic so that the size of the tuples is not fixed, you should specify the layout. For instance in the following you actually have 3 4-tuples, but the code handles any data length and size of sub-arrays:

# A 2-dimensional piece of data
data = [(20.0,20.0,320.0,20.0), (20.0,20.0,320.0,20.0), (20.0,20.0,320.0,20.0)]
# Flatten data
msg.data = [v for nested in data for v in nested]
# Specify the layout of the 2 dimensions
dim0 = MultiArrayDimension()
dim0.label = "foo"
# First dimension size is the number of nested tuples
dim0.size = len(data)
# First stride is defined as the total data size
dim0.stride = len(msg.data)

dim1 = MultiArrayDimension()
dim1.label = "bar"
# Second dimension size is the length of individual nested tuples
dim1.size = len(data[0])
# Second (last) stride is equal to the size when there is no padding
dim1.stride = dim1.size

msg.layout.dim = [dim0, dim1]

As you see this gets relatively complex, and includes things you probably don't want to care about, like strides and padding. This is a good sign that you indeed probably should make your own custom message, that has just the fields you need, with explicit names fitting your use case (e.g. angles).


text:
Dividends

The three friends divided the win by the invested money. Karlos got three eighths John 320 permille and the rest got Martin. Who got the most and which the least?

Result

k =  0.375
j =  0.32
m =  0.305

Solution:

$k=3/8=\dfrac{ 3 }{ 8 }=0.375$
$j=320/1000=\dfrac{ 8 }{ 25 }=0.32$
$m=1-k-j=1-0.375-0.32=\dfrac{ 61 }{ 200 }=0.305 \ \\ m

Our examples were largely sent or created by pupils and students themselves. Therefore, we would be pleased if you could send us any errors you found, spelling mistakes, or rephasing the example. Thank you!

Leave us a comment of this math problem and its solution (i.e. if it is still somewhat unclear...):

Showing 1 comment:
Math student
Karlos got the most  , Martin lowest

Tips to related online calculators
Need help calculate sum, simplify or multiply fractions? Try our fraction calculator.

Next similar math problems:

1. There
There are 32 trees of three species in the orchard. 25% cherries, three eighty pears, others plums. How many plums are in the orchard?
2. Three monks
Three medieval monks has task to copy 600 pages of the Bible. One rewrites in three days 1 page, second in 2 days 3 pages and a third in 4 days 2 sides. Calculate for how many days and what day the monks will have copied whole Bible when they begin Wednes
3. Discounts 2
The local fitness center offers membership discounts for hospital employees. According to the membership brochure, you will receive a discount of 25% on a membership that normally costs \$65 per month. How much will you pay for an annual membership if you
4. Discount sale
At Christmas Sale after a 20% discount cosmetic package was priced at a price of 5 euros and 60 cents; later it went to 3 euros and 80 cents. How much percentage is the total discount?
5. Insect spraying
In 600 ml of spraying is 5 ml of an active ingredient. How much is it per miles?
6. Apples 14
Maya bought 18 apples. She used 50% of the apples to make apple pies and 1/3 of the apples was mixed with other fruits to make salad. How many apples were left?
7. Mixed2improper
Write the mixed number as an improper fraction. 166 2/3
8. Winery
The wine processing plant sold 8/15 of its total wine production to the domestic market, 2/7 to the foreign the rest of the wine. How many percents are still in stock?
9. In fractions
An ant climbs 2/5 of the pole on the first hour and climbs 1/4 of the pole on the next hour. What part of the pole does the ant climb in two hours?
10. Equation with mixed fractions
2 3/5 of 1430+? = 1900. How to do this problem
11. Fraction to decimal
Write the fraction 3/22 as a decimal.
12. Profit gain
If 5% more is gained by selling an article for Rs. 350 than by selling it for Rs. 340, the cost of the article is:
13. Equivalent fractions
Are these two fractions equivalent -4/9 and 11/15?
14. Lengths of the pool
Miguel swam 6 lengths of the pool. Mat swam 3 times as far as Miguel. Lionel swam 1/3 as far as Miguel. How many lengths did mat swim?
15. What percent
What percent of 51 3/5 is 47 2/5?
16. Zdeněk
Zdeněk picked up 15 l of water from a 100-liter full-water barrel. Write a fraction of what part of Zdeněk's water he picked.
17. Compare
Compare with characters >, <, =: 85.57 ? 80.83


text:
# Sum Rule for Complex Derivatives

 It has been suggested that this page or section be merged into Combination Theorem for Complex Derivatives/Sum Rule. (Discuss)

## Theorem

Let $\map f z, \map j z, \map k z$ be single-valued continuous complex functions in a domain $D \subseteq \C$, where $D$ is open.

Let $f$, $j$, and $k$ be complex-differentiable at all points in $D$.

Let $\map f z = \map j z + \map k z$.

Then:

$\forall z \in D: \map {f'} z = \map {j'} z + \map {k'} z$

## Proof

Let $z_0 \in D$ be a point in $D$.

 $\ds \map {f'} {z_0}$ $=$ $\ds \lim_{h \mathop \to 0} \frac {\map f {z_0 + h} - \map f {z_0} } h$ Definition of Derivative of Complex Function $\ds$ $=$ $\ds \lim_{h \mathop \to 0} \frac {\paren {\map j {z_0 + h} + \map k {z_0 + h} } - \paren {\map j {z_0} +\map k {z_0} } } h$ $\ds$ $=$ $\ds \lim_{h \mathop \to 0} \frac {\map j {z_0 + h} + \map k {z_0 + h} - \map j {z_0} - \map k {z_0} } h$ $\ds$ $=$ $\ds \lim_{h \mathop \to 0} \frac {\paren {\map j {z_0 + h} - \map j {z_0} } + \paren {\map k {z_0 + h} - \map k {z_0} } } h$ $\ds$ $=$ $\ds \lim_{h \mathop \to 0} \paren {\frac {\map j {z_0 + h} - \map j {z_0} } h + \frac {\map k {z_0 + h} - \map k {z_0} } h}$ Complex Multiplication Distributes over Addition $\ds$ $=$ $\ds \lim_{h \mathop \to 0} \frac {\map j {z_0 + h} - \map j {z_0} } h + \lim_{h \mathop \to 0} \frac {\map k {z_0 + h} - \map k {z_0} } h$ Sum Rule for Limits of Complex Functions $\ds$ $=$ $\ds \map {j'} {z_0} + \map {k'} {z_0}$ Definition of Derivative of Complex Function $\ds \leadsto \ \$ $\, \ds \forall z \in D: \,$ $\ds \map {f'} z$ $=$ $\ds \map {j'} z + \map {k'} z$ Definition of Derivative of Complex Function

$\blacksquare$


text:
# open¶

baseband.vdif.open(name, mode='rs', **kwargs) [edit on github]

Open VDIF file(s) for reading or writing.

Opened as a binary file, one gets a wrapped filehandle that adds methods to read/write a frame. Opened as a stream, the handle is wrapped further, with methods such as reading and writing to the file as if it were a stream of samples.

Parameters
namestr or filehandle, or sequence of str

File name, filehandle, sequence of file names, or template (file name(s) can be Path but template has to be str).

mode{‘rb’, ‘wb’, ‘rs’, or ‘ws’}, optional

Whether to open for reading or writing, and as a regular binary file or as a stream. Default: ‘rs’, for reading a stream.

**kwargs

Additional arguments when opening the file as a stream.

sample_rateQuantity, optional

Number of complete samples per second, i.e. the rate at which each channel in each thread is sampled. If None (default), will be inferred from the header or by scanning one second of the file.

squeezebool, optional

If True (default), remove any dimensions of length unity from decoded data.

subsetindexing object or tuple of objects, optional

Specific components of the complete sample to decode (after possible squeezing). If a single indexing object is passed, it selects threads. If a tuple is passed, the first selects threads and the second selects channels. If the tuple is empty (default), all components are read.

fill_valuefloat or complex, optional

Value to use for invalid or missing data. Default: 0.

verifybool, optional

Whether to do basic checks of frame integrity when reading. The first frameset of the stream is always checked. Default: True.

— For writing a stream
header0VDIFHeader

Header for the first frame, holding time information, etc. Can instead give keyword arguments to construct a header (see **kwargs).

sample_rateQuantity

Number of complete samples per second, i.e. the rate at which each channel in each thread is sampled. For EDV 1 and 3, can alternatively set sample_rate within the header.

Number of threads (e.g., 2 for 2 polarisations). Default: 1.

squeezebool, optional

If True (default), writer accepts squeezed arrays as input, and adds any dimensions of length unity.

file_sizeint or None, optional

When writing to a sequence of files, the maximum size of one file in bytes. If None (default), the file size is unlimited, and only the first file will be written to.

**kwargs

If no header is given, an attempt is made to construct one from these. For a standard header, this would include the following.

timeTime

Start time of the file. Can instead pass on ref_epoch and seconds.

nchanint, optional

Number of channels (default: 1). Note: different numbers of channels per thread is not supported.

complex_databool, optional

Whether data are complex. Default: False.

bpsint, optional

Bits per elementary sample, i.e. per real or imaginary component for complex data. Default: 1.

samples_per_frameint

Number of complete samples per frame. Can alternatively use frame_length, the number of 8-byte words for header plus payload. For some EDV, this number is fixed (e.g., frame_length=629 for edv=3, which corresponds to 20000 real 2-bit samples per frame).

station2 characters, optional

Station ID. Can also be an unsigned 2-byte integer. Default: 0.

edv{False, 0, 1, 2, 3, 4, 0xab}

Extended Data Version.

Notes

One can also pass to name a list, tuple, or subclass of FileNameSequencer. For writing to multiple files, the file_size keyword must be passed or only the first file will be written to. One may also pass in a sequentialfile object (opened in ‘rb’ mode for reading or ‘w+b’ for writing), though for typical use cases it is practically identical to passing in a list or template.


text:
# Solve differential equation dx/dy+x/y= 1/(sqrt(1+y^2))

Question
Solve differential equation $$dx/dy+x/y= 1/(sqrt(1+y^2))$$

2020-11-28
$$dx/dy+p(y)x=q(y)$$
Compare the equation $$dx/dy+p(y)x=q(y)$$ to $$dx/dy+x/y= 1/(sqrt(1+y^2))$$ and obtain $$p(y)=1/y$$, $$q(y)= 1/(sqrt(1+y^2))$$
$$I.F.= e^(int p(y)dy)$$
$$= e^(ln y)$$
=y $$xe^(int p(y)dy)= int e^(int p(y)dy)q(y)dy+C$$
where C is arbitrary constant of equation
$$xe^(int p(y)dy)= int e^(int p(y)dy)q(y)dy+C$$
$$xy= int y 1/(sqrt(1+y^2))dy+C$$
$$xy= 1/2 int (2y)/(sqrt(1+y^2)) dy+C$$
$$xy= 1/2 int ((1+y^2)')/(sqrt(1+y^2)) dy+C$$ [$$:' (1+y^2)'= 2y$$]
$$xy= 1/2 (2 sqrt(1+y^2))+C$$ [$$:' int (f(y))/(sqrt(f(y)))dy= 2 sqrt(f(y))$$]
$$xy= sqrt(1+y^2)+C$$
$$x= (sqrt(1+y^2)+C)/y$$
$$x= (sqrt(1+y^2))/y+C/y$$

### Relevant Questions

Solve differential equation $$xy'+2y= -x^3+x, \ y(1)=2$$

Solve differential equation $$\frac{\cos^2y}{4x+2}dy= \frac{(\cos y+\sin y)^2}{\sqrt{x^2+x+3}}dx$$

Consider the curves in the first quadrant that have equationsy=Aexp(7x), where A is a positive constant. Different valuesof A give different curves. The curves form a family,F. Let P=(6,6). Let C be the number of the family Fthat goes through P.
A. Let y=f(x) be the equation of C. Find f(x).
B. Find the slope at P of the tangent to C.
C. A curve D is a perpendicular to C at P. What is the slope of thetangent to D at the point P?
D. Give a formula g(y) for the slope at (x,y) of the member of Fthat goes through (x,y). The formula should not involve A orx.
E. A curve which at each of its points is perpendicular to themember of the family F that goes through that point is called anorthogonal trajectory of F. Each orthogonal trajectory to Fsatisfies the differential equation dy/dx = -1/g(y), where g(y) isthe answer to part D.
Find a function of h(y) such that x=h(y) is the equation of theorthogonal trajectory to F that passes through the point P.
Solve differential equation $$\displaystyle{y}{\left({2}{x}-{2}+{x}{y}+{1}\right)}{\left.{d}{x}\right.}+{\left({x}-{y}\right)}{\left.{d}{y}\right.}={0}$$
Solve differential equation $$\displaystyle{\frac{{{\left.{d}{y}\right.}}}{{{\left.{d}{x}\right.}}}}={\left({x}+{y}+{1}\right)}^{{2}}-{\left({x}+{y}-{1}\right)}^{{2}}$$
Solve differential equation $$\displaystyle{2}{x}{y}-{9}{x}^{{2}}+{\left({2}{y}+{x}^{{2}}+{1}\right)}{\frac{{{\left.{d}{y}\right.}}}{{{\left.{d}{x}\right.}}}}={0},\ {y}{\left({0}\right)}=-{3}$$
Solve differential equation $$2xy-9x^2+(2y+x^2+1)dy/dx=0$$, y(0)= -3
Solve differential equation $$dy/dx= (y^2-1)/(x^2-1)$$
Solve differential equation $$1+y^2+xy^2)dx+(x^2y+y+2xy)dy=0$$
Solve differential equation $$(y2+1)dx=ysec^2(x)dy$$, y(0)=0


text:
# Integration-Problem with substitution

1. Nov 12, 2009

### jameson2

1. The problem statement, all variables and given/known data
I have reached this integration from a mechanics problem about small angle scattering. t= (2pa/mv^2)*(int from p to infinity) [r*dr]/[((b^2 +r^2)^(3/2))(sqrt(r^2 - p^2))]

2. Relevant equations

3. The attempt at a solution
I know that there should be a substitution that will make this an easy problem, but I can't find it. I've tried the simple ones like let y=r^2, or y=b^2 + r^2, but they didn't get me anywhere.

2. Nov 12, 2009

### Staff: Mentor

For further reference, here is your integral in a more readable form:
$$\frac{2pa}{mv^2}\int_{r = p}^{\infty}\frac{r~dr}{(b^2 + r^2)^{3/2}\sqrt{r^2 - p^2}}$$

You might try an ordinary substitution of u = r2 - p2, but I'm not sure that will do you much good. Next I would try a trig substitution, sec $\theta$ = r/p.